/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#pragma once

#include "Context/当前默认操作数据.h"

#include <lua.hpp>



// 语法块类型枚举
enum BlockType {
	BLOCK_IF,       // if ... end
	BLOCK_FOR,      // for ... do ... end
	BLOCK_WHILE,    // while ... do ... end
	BLOCK_FUNCTION, // function ... end
	BLOCK_DO,       // do ... end
	BLOCK_REPEAT,   // repeat ... until
	BLOCK_TABLE     // { ... }
};

enum class E_代码解析状态 {
	e_语法正确且完整,
	e_语法不完整,
	e_语法错误,
};

// 语法块配对映射
struct BlockPair {
	const char *start;    // 开始关键字
	const char *end;      // 结束关键字
	BlockType type;       // 块类型
};

// 解析上下文
struct S_ParseContext {
	bool in_single_quote = false;
	bool in_double_quote = false;
	bool in_multi_comment = false;
	std::stack<BlockType> block_stack;
};


bool f_lua_语法快检测(const std::string &code);

//bool f_lua_检查代码是否完整(lua_State *L, const std::string &code);

bool f_lua_是否为单个变量(const std::string &code);

bool f_lua_是否为表达式(const std::string &code);

bool f_lua_基础语法检查(const std::string &code);

bool f_lua_是否为声明(const std::string &code);




bool f_lua_互式输入特有的错误信息(const std::string& error, const std::string& code);



